package com.example.system.tools;


import lombok.Data;
import lombok.experimental.Accessors;

/**
 *  @Description： 返回数据封装类
 *  @date  2019/5/6 14:18
 *  @Version 1.0
 *
**/
@Data
@Accessors(chain = true)
public class ResultHelper {
    /**
     * 数据请求状态
     */
    private String status;
    /**
     * 请求消息
     */
    private String message;
    /**
     * 请求结果
     */
    private Object data;

    /**
    * @Description: 失败消息
    * @CreateTime: 17:07
    * @Version: 1.0
     *
    * @param failMsg 失败消息
    * @return
    */
    public static ResultHelper fail(String failMsg){
        ResultHelper resultHelper = new ResultHelper();
            resultHelper.setStatus(ResultEnum.FAIL.getCode());
            resultHelper.setMessage(failMsg);
        return resultHelper;
    }

    /**
     *  @Description： 操作成功
     *  @date  2019/5/6 14:29
     *  @Version 1.0
     *
     * @param data 返回数据
     * @return
     */
    public static ResultHelper success(Object data){
        ResultHelper resultHelper = new ResultHelper();
            resultHelper.setStatus(ResultEnum.SUCCESS.getCode());
            resultHelper.setMessage(ResultEnum.SUCCESS.getMsg());
            resultHelper.setData(data);
        return resultHelper;
    }

    /**
    * @Description: 操作成功
    * @CreateTime: 17:10
    * @Version: 1.0
     *
     * @param successMsg 成功消息
     * @param data 返回数据
     * @return
     */
    public static ResultHelper success(String successMsg, Object data){
        ResultHelper resultHelper = new ResultHelper();
            resultHelper.setStatus(ResultEnum.SUCCESS.getCode());
            resultHelper.setMessage(successMsg);
            resultHelper.setData(data);
        return resultHelper;
    }
}